package com.leetcode.LC;

public class LC724 {
    public int pivotIndex(int[] nums) {

        int a = 0, b = 0;
        int[] ints = new int[nums.length];
        int[] ints1 = new int[nums.length];
        for (int i = 0; i < nums.length; i++) {
            a += nums[i];
            ints[i] = a;
            b += nums[nums.length - i - 1];
            ints1[nums.length - i - 1] = b;
        }

        int k = -1;
        for (int i = 0; i < nums.length; i++) {
            if (ints[i] == ints1[i]) {
                return i;
            }
        }
        return k;
    }

    public static void main(String[] args) {
        System.out.println(new LC724().pivotIndex(new int[]{2,1,-1}));
    }
}
